<?php

//============================================================+
// File name   : pononprepack.php
// Begin       : 2012-11-09
// Last Update : 2012-11-09
//
// Description : This is gen Po Pre Pack Layout to pdf file.
//               
//
// Author: Edo Wong
//
//============================================================+

/**
 * Creates Po Pre Pack Layout to pdf file using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract  Po Pre Pack Layout 
 * @author Edo Wong
 * @since  2012-11-09
 */


require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
date_default_timezone_set('Asia/Taipei');


// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {


	//Page header
	public function Header() {
		// Logo
		//$image_file = K_PATH_IMAGES.'logo_example.jpg';
		//$this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
		// Set font
		$this->SetFont('helvetica', 'B', 16);
		// Title
       
        

        //$connectDB = new mysql("localhost","root","asdfghjkl","edi_db_testsap","edidb","utf8");
		//$result = $connectDB->conditionfind("po_hdr","where po_no='4700002399'");
        //$result2 = $connectDB->fetch_row($result);

		$this->Cell(0, 10, "AEO Management Co.", 0, 1, 'C', 0, '', 0, false, 'M', 'M');
        
 		$this->SetFont('helvetica','', 8);
		$this->Cell(0, 10, "Brand: AMERICAN EAGLE OUTFITTERS", 0, 1, 'C', 0, '', 0, false, 'M', 'M');
		
        $this->SetFont('helvetica','', 8);
		$this->Cell(0, 10, "Selling Channel: STORE", 0, 1, 'C', 0, '', 0, false, 'M', 'M');
        
        // Position at 15 mm from bottom

        $this->SetX(130);
		$this->SetFont('helvetica','', 9);
		$this->Cell(0, 8, "Purchase Order No  :     ", 0, 1, 'C', 0, '', 0, false, 'M', 'M');
        $this->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)));
        $this->SetFillColor(255,255,255);
//$this->SetTextColor(0,0,255);
		$this->SetY(17);
        $this->SetX(177);
        $this->MultiCell(30, 4, "????", 1, 'C', 1, 0);
        
		$this->SetY(25);
		$this->SetX(145);
        $this->SetFont('helvetica','', 9);
		$this->Cell(0, 10, "Revision No. :    ??", 0, 1, 'C', 0, '', 0, false, 'M', 'M');

        
       
        $this->SetTopMargin(32);  
        
        
	}
    
    
    	// Page footer
	public function Footer() {
	   
		// Position at 15 mm from bottom
		//$this->SetY(-15);
        //$this->SetY(260);
        //$this->SetX(500);
		// Set font
		$this->SetFont('helvetica', '', 8);
		// Page number
		$this->SetY(275);
        $this->Cell(0, 0, 'The terms and conditions for this Purchase Order are set forth in the American Eagle Outfitters, Inc. Master Purchase Agreement and in the', 0, 1, 'C', 0, '', 0, false, 'T', 'M');
        $this->Cell(0, 0, 'American Eagle Outfitters Corporate Vendor Manual, which are incorporated herein by reference. Acknowledging receipt of this PO is acceptance', 0, 1, 'C', 0, '', 0, false, 'T', 'M');
        $this->Cell(0, 0, 'of the terms and conditions by vendor. No variation in the terms and conditions is effective.', 0, 1, 'C', 0, '', 0, false, 'T', 'M');
		 
         
        $this->SetY(290);
        $this->SetX(190);
		// Set font
		$this->SetFont('helvetica', '', 8);
		// Page number
		//$this->Cell(0, 15, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
		$this->Cell(0, 8, 'Page : '.$this->getAliasNumPage().' of '.$this->getAliasNbPages(), 0, 1, 'C', 0, '', 0, false, 'M', 'M');
            
	}

}


// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 003');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// set font
$pdf->SetFont('times', '', 10);

// add a page
$pdf->AddPage();

$orderha = <<<EOD
PURCHASE ORDER:<br />
<table width="700" height="320" border="1">
  <tr>
    <td colspan="2"><b>TO:&nbsp;&nbsp;&nbsp;AAAAAAAAAAAAAAA<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BBBBBBBBBBBBBB<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CCCCCCCCCCCCCCCCC</b></td>
    <td colspan="2"><b>Bill<br />To:</b></td>

  </tr>
  <tr>
    <td width="33%"><b>Ship<br />To:</b></td>
    <td width="33%" colspan="2">Start Ship<br />Last Hand Over Date</td>
    <td width="34%">&nbsp;</td>
  </tr>
    <tr>
    <td>Country of Origin<br />Terms</td>
    <td colspan="2">PO Status<br />PO Status Date<br />PO Initiated<br /></td>
    <td>Buyer<br />Department<br />Floorset<br /></td>
  </tr>
</table>
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderha, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

$orderhb = <<<EOD
<br /><br /><br />
<table width="700" height="320" border="1">
  <tr>
    <td><b>PO Comments:</b></td>
    
  </tr>
</table>
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderhb, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);


$orderhc = <<<EOD
<br /><br /><br />
<table width="700" height="320" border="1">
  <tr>
    <td><b>Floor Ready Comments:</b><br /></td>
    
  </tr>
</table>
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderhc, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);


$orderhd = <<<EOD
<br /><br /><br />
<table width="700" height="320" border="1">
  <tr>
    <td><b>TICKET INFORMATION</b><br />Ticket Type.....<br />To Vendor by..</td>
    <td><b>TICKET ADDRESS</b><br /></td>
  </tr>
</table>
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderhd, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

$pdf->SetY(252);
$orderhd = <<<EOD
<br /><br /><br />
<table width="700" height="320" border="0">
  <tr>
    <td></td>

    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>TOTAL ORDER SUMMARY</b></td>
    
    <td></td>
  </tr>
</table>
<table width="700" height="320" border="1">
  <tr>
    <td>UNITS</td>
    <td>FIRST COST</td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderhd, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
//next page

$pdf->AddPage();

$orderda = <<<EOD
??
EOD;
// print a block of text using Write()
$pdf->writeHTMLCell($w=0, $h=0, $x='2', $y='', $orderda, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);


$pdf->Output("example.pdf", "I");
?>